#include <iostream>
#include <unordered_map>
using namespace std;

int n,m;
unordered_map<int,int> cnt;

bool check(int x)
{
    int g = 0;
    for(auto&[a,b]:cnt)
    {
        g+=b/x + (b%x==0?0:1);
    }
    return g<=m;
}

int main()
{
    cin >> n >> m;
    int hmax = 0;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        hmax = max(hmax,++cnt[x]);
    }

    int kinds = cnt.size();
    if(kinds > m)
    {
        cout << -1 << endl;
    }
    else{
        int l = 1,r = hmax;
        while(l < r)
        {
            int mid = (l+r)/2;
            if(check(mid))
            {
                r = mid;
            }
            else
            {
                l = mid + 1;
            }
        }
        cout << l << endl;
    }
}

